package com.mspbots.core.teams;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.mspbots.core.AbstractBaseController;
import com.mspbots.core.teams.model.TeamsUserNoMessage;
import com.mspbots.core.teams.service.TeamsUserNoMessageService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * @author billb
 */
@RestController
@RequestMapping("/teams/no-message/user/")
public class TeamsUserNoMessageController extends AbstractBaseController<TeamsUserNoMessage, TeamsUserNoMessageService> {

    @PostMapping(path = "insertBatch/{tenantId}")
    public Callable insertBatch(@PathVariable Long tenantId, @RequestBody List<TeamsUserNoMessage> list) {
        return () -> service.insertBatch(tenantId, list);
    }

    @GetMapping(path = "deleteBatch")
    public Callable deleteBatch(TeamsUserNoMessage query) {
        return () -> service.remove(Wrappers.<TeamsUserNoMessage>lambdaQuery()
                .eq(ObjectUtils.isNotEmpty(query.getTenantId()), TeamsUserNoMessage::getTenantId, query.getTenantId())
                .ne(TeamsUserNoMessage::getCheckTime, query.getCheckTime()));
    }
}
